<template>
	<view>
		<view class="input_box">
			<view>
				<view style="height: 80rpx;line-height: 80rpx;">内容描述</view>
				<u-input v-model="value" type="textarea" placeholder="请输入内容" />
			</view>
			<view class="">
				<u-upload :action="action" ref="uUpload" :auto-upload="true" :file-list="fileList"></u-upload>
			</view>
		</view>
		<view class="btn_fix">
			<view class="btn" @click="submit">提交</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				value: '',
				id: '',
				action: this.$store.state.baseUrl + "common/up/single",
				fileList: []
			}
		},
		onLoad(e) {
			this.id = e.id
		},
		methods: {
			async submit() {
				let that = this
				let files = [];
				// 通过filter，筛选出上传进度为100的文件(因为某些上传失败的文件，进度值不为100，这个是可选的操作)
				files = this.$refs.uUpload.lists.filter(val => {
					return val.progress == 100;
				})
				// 如果您不需要进行太多的处理，直接如下即可
				// files = this.$refs.uUpload.lists;
				console.log(files)
				let res = await this.$request('kehu/jiajiaCharityActivitiesEnroll/edit', {
					content: this.value,
					url:  files[0].response.url,
					id: this.id
				})
				if (res.msg == '操作成功') {
					uni.showToast({
						title: '提交成功，等待审核',
						icon: 'none'
					})
				}
			}
		}
	}
</script>

<style>
	.input_box {
		width: 710rpx;
		padding: 20rpx 30rpx;
		background-color: #fff;
		margin-left: 20rpx;
		margin-top: 30rpx;
	}

	.btn {
		width: 686rpx;
		height: 80rpx;
		text-align: center;
		line-height: 80rpx;
		color: #fff;
		background-color: #2869FE;
		border-radius: 8rpx;
	}

	.btn_fix {
		position: fixed;
		bottom: 5%;
		left: 32rpx;
	}
</style>